<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script type="text/javascript" src="../../jquery-2.1.1.js"></script>
<script type="text/javascript">
  jQuery.fn.adv = function(imgs,timer){
    var index = 0;
    var selector = this.selector;
    var img = new Image();
    img.src = imgs[index];
    img.onload = function(){
        $(selector).append(img);
    }
    setInterval(function(){
        $(selector).html("");
        index ++;
        if(index >= imgs.length){
            index = 0;
        }
        img.src = imgs[index];
        img.onload = function(){
            $(selector).append(img);
        }
    },timer);
}

</script>
<script>
    var imgs = ["1.png","2.png","lb3.png","lb4.png"];
    $("#adv").adv(imgs,5000);
</script>

 </head>
 <body>
  <div id="adv" style="width:735px;height:320px;border:1px solid #999999;"></div>
</body>
</html>
